//聊天界面
import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import QtQml 2.12
Rectangle {
    visible: true
    width: 640
    height: 480


    ListModel {
        id: rectangleModel
        ListElement { color1: "black" }
        ListElement { color1: "black" }
        ListElement { color1: "black" }
        ListElement { color1: "black" }
        ListElement { color1: "black" }
    }

    ListView {
        id: rectangleList
        anchors.fill: parent
        model: rectangleModel
        spacing:20
        delegate:     Rectangle{
            id:rectangleDelegate
            height:50
            width:200
            color:color1
            MouseArea {
                anchors.fill: parent
                hoverEnabled: true
                onEntered: {
                //鼠标移入
                    console.log(index+"鼠标移入")
                    if(rectangleDelegate.color==="red"){
                    return
                    }
                    rectangleDelegate.color==="gry"
                    }

                onExited: {
                              console.log(index+"鼠标移出")
                //鼠标移出
                }
                onClicked: {
                    if (rectangleDelegate.color !== "red") {
                        rectangleDelegate.color = "red"
                        for (let i = 0; i < rectangleList.count; ++i) {
                            if (rectangleList.itemAt(i) !== rectangleDelegate) {
                                rectangleList.itemAt(i).color = "black"
                            }
                        }
                    }
                }
            }

        }

    }


}

// Custom Rectangle Delegate

